
# define macro
define show_task
    set var $tsk = $arg0
    print $tsk
    print $tsk->comm
    print $tsk->cpus_mask
end
document show_task
    show_task var
end

# execute while do source
show language

#### python demo ####
python
# execute while do source
lang = gdb.execute("show language", to_string=True)
print(f"python result: {lang}", end='')
end

python
# invoke from cli
# Usage: hihi
class Hi(gdb.Command):
    """hello gdb"""
    def __init__ (self):
        super(Hi, self).__init__("hihi", gdb.COMMAND_USER)

    def invoke(self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) != 0:
            raise gdb.GdbError("hihi takes no arguments")
        print("Hello, World!")

Hi()
end
